package com.baijiayun.liveuibase.widgets.courseware;

import com.baijiayun.livecore.context.LiveRoom;
import com.baijiayun.livecore.models.LPDocTranslateProgressModel;
import com.baijiayun.livecore.models.LPUploadHomeworkUserModel;
import com.baijiayun.livecore.models.LPUploadingDocumentModel;
import com.baijiayun.livecore.models.courseware.LPMediaCoursewareModel;
import com.baijiayun.livecore.models.file.IFileModel;
import com.baijiayun.livecore.models.file.cloudfile.LPCloudFileModel;
import com.baijiayun.livecore.models.file.homework.LPHomeworkModel;
import com.baijiayun.livecore.models.file.homework.LPResHomeworkAllModel;
import com.baijiayun.livecore.viewmodels.impl.LPDocListViewModel;
import com.baijiayun.liveuibase.widgets.courseware.models.UploadDocModel;

import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.util.List;

public class BaseCourseWareContract {

    public interface BaseCourseWareView {
        /**
         * 增加 上传 item
         * @return item 是否合法
         */
        boolean addUploadModel(LPUploadingDocumentModel model);

        void removeUploadDocument(String path);

        void uploadProgress(String filePath, int progress);

        /**
         * 开始转码，并保存响应参数
         */
        void startTranslate(LPUploadingDocumentModel model);

        void translateProgress(String filePath, int progress);

        void uploadFailure(LPUploadingDocumentModel model, String msg);

        void translateFailure(LPUploadingDocumentModel model, LPDocTranslateProgressModel progressModel);

        void onDownloadSuccess(String homeworkId);

        void onDownloadProgress(String homeworkId, float progress);

        void onDownloadFailed(String homeworkId, String msg);

        void updateAllDocList(@NotNull List<LPDocListViewModel.DocModel> allDocList);

        void updateMediaCoursewareList(List<LPMediaCoursewareModel> mediaCoursewareModelList);

        void updateAllHomework(@NotNull LPResHomeworkAllModel homeworkAll);

        void updateHomeworkSearchRst(LPResHomeworkAllModel searchRst);

        void updateAllCloudFile(List<LPCloudFileModel> allCloudFile);

        void updateHomeworkSupport(boolean support);

        void updateAllowUpdateHomework(boolean isAllow);

        void updateCloudDirRecord(List<LPCloudFileModel> dirRecordModels);
    }

    public interface BaseCourseWarePresenter {

        void sendImageShape(String path, boolean isCloudFile);

        void sendChatImageShape(String path);

        void sendPPTDocument(String path, boolean isAnimPPT);

        void cancelUpload(String path);

        void sendPPTCloudFile(String path, boolean isAnimPPT, boolean isImg);

        void sendHomeWork(String path, boolean isImg);

        void deleteHomework(String homeworkId, LPUploadHomeworkUserModel userModel);

        /**
         * 取消转码中的进程
         */
        void deleteTranslating(UploadDocModel uploadDocModel);

        void downloadHomework(LPHomeworkModel homeworkModel, File file);

        void requestCloudFileInDir(LPCloudFileModel dirFileModel);

        void requestSearchHomework(String keyword);

        void cancelDownloadHomework(File file);

        void requestHomeworkSupport();

        /**
         * 检查 文件是否已添加到 doc_list
         * 如有，则调用 {@link IOnRequestTransferListener#onSuccess(LPDocListViewModel.DocModel)}
         * 如无，则会 doc_add 并调用 {@link IOnRequestTransferListener#onWaitForDocAdd()}
         * @param fileModel 要查询的文件 model
         * @param listener 文件状态回调
         */
        void requestFileTransfer(IFileModel fileModel, BaseCourseWareContract.IOnRequestTransferListener listener);

        boolean playDoc(LPDocListViewModel.DocModel docModel);

        void playMediaCourseware(LPMediaCoursewareModel toPlayMedia);

        void playBds(LPDocListViewModel.DocModel bdsModel);

        boolean enableImageShowAsDoc();

        void subscribe(LiveRoom liveRoom);

        void unSubscribe();

        void destroy();
    }

    public interface IOnRequestTransferListener {
        void onSuccess(LPDocListViewModel.DocModel docModel);
        void onWaitForDocAdd();
    }
}
